{layout name="public/layout" /}

        {include file='yxnavbar'}
<div class="main">
    <ul class="nav nav-tabs">
		<li {if $action < 2}class="active"{/if}><a href="{php echo createWebUrl('shengshi');}">城市列表</a></li>
        <li {if $action == 2}class="active"{/if}><a href="{php echo createWebUrl('shengshi', array('action' =>2));}">抢定城市</a></li>
        <li {if $action == 3}class="active"{/if}><a href="{php echo createWebUrl('shengshi', array('action' =>3));}">内定城市</a></li>

    </ul>
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$total}</div>
        
    </div>
  <div class="panel panel-default">

    {if $pagelevel == 1 }
        <div class="panel-body table-responsive"> 
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:60px;">序号</th>
                        <th style="width:80px;">全国</th>
                        <th style="width:80px;">省份</th>
                        <th style="">查看</th>

                        <th style=" text-align:right;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $i $item}
                  <tr> 
                    <td>{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td><a href="{php echo createWebUrl('shengshi');}">全国</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' =>$item['areaId'],'pagelevel' =>2,'shengname' =>$item['areaName']));}">{$item['areaName']}</a></td>
                    <td><a class="btn btn-success btn-sm" href="{php echo createWebUrl('shengshi', array('parentId' =>$item['areaId'],'pagelevel' =>2,'shengname' =>$item['areaName']));}">查看下级</a></td>
                    <td style="text-align:right;"> 

                      <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'edit','areaId' =>$item['areaId'],'parentName' =>'全国省份'));}" title="编辑"><i class="icon-edit"></i>编辑</a>
                      <a href="{php echo createWebUrl('shengshi', array('op' =>'delete','areaId' =>$item['areaId']));}" style="width: 30px" class="btn btn-danger btn-sm" onclick="if(!confirm('确定删除吗,不可恢复')) return false;"  title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                    </td>
                </tr>
                {/loop}
            </tbody>
            </table>
            <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'add','parentId' =>-1,'pagelevel' =>1, 'parentName' =>'全国省份'));}" title="新增"><i class="icon-edit"></i>新增省份</a>
        </div>
    {elseif $pagelevel == 2}
        <div class="panel-body table-responsive"> 
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:60px;">序号</th>
                        <th style="width:80px;">全国</th>
                        <th style="width:80px;">省份</th>
                        <th style="width:80px;">市级</th>
                        <th style="">查看</th>

                        <th style=" text-align:right;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $i $item}
                  <tr> 
                    <td>{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td><a href="{php echo createWebUrl('shengshi');}">全国</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' => $parentId,'pagelevel' =>2,'shengname' =>$shengname));}">{$shengname}</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' =>$item['areaId'],'pagelevel' =>3,'shengname' =>$shengname,'shengid' =>$parentId,'shiname' =>$item['areaName']));}">{$item['areaName']}</a></td>
                    <td><a class="btn btn-success btn-sm" href="{php echo createWebUrl('shengshi', array('parentId' =>$item['areaId'],'pagelevel' =>3,'shengname' =>$shengname,'shengid' =>$parentId,'shiname' =>$item['areaName']));}">查看下级</a></td>
                    <td style="text-align:right;"> 

                      <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'edit','areaId' =>$item['areaId'],'parentName' =>$shengname));}" title="编辑"><i class="icon-edit"></i>编辑</a>

                      <a href="{php echo createWebUrl('shengshi', array('op' =>'delete','areaId' =>$item['areaId']));}" style="width: 30px" class="btn btn-danger btn-sm" onclick="if(!confirm('确定删除吗,不可恢复')) return false;"  title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                    </td>
                </tr>
                {/loop}
            </tbody>
            </table>
            <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'add','parentId' =>$parentId,'pagelevel' =>2, 'parentName' =>$shengname));}" title="新增"><i class="icon-edit"></i>新增市级</a>
        </div>

    {elseif $pagelevel ==3}
        <div class="panel-body table-responsive"> 
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:60px;">序号</th>
                        <th style="width:80px;">全国</th>
                        <th style="width:80px;">省份</th>
                        <th style="width:80px;">市级</th>
                        <th style="width:80px;">县/区</th>
                        <th style="width:80px;">城市级别</th>
                        <th style="width:80px;">加盟状态</th>
                        <th >内定</th>
                        <th >备注</th>
                        <th style=" text-align:right;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $i $item}
                  <tr> 
                    <td>{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td><a href="{php echo createWebUrl('shengshi');}">全国</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' => $shengid,'pagelevel' =>2,'shengname' =>$shengname));}">{$shengname}</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' =>$parentId,'pagelevel' =>3,'shengname' =>$shengname,'shengid' =>$shengid,'shiname' =>$shiname));}">{$shiname}</a></td>
                    <td>{$item['areaName']}</td>
                    <td>{$level[$item['level']]}</td>
                    <td>{if !empty($item['recordid'])}
                        {if $item['recordid']==99999}
                        内定
                        {else}
                    <a href="{php echo createWebUrl('record', array('op2' => 'scan','themeid'=>$themeid, 'id' => $item['recordid']));}" title="查看定单" ><span class="label label-success">已抢定{php echo $item['recordid']+10000;}</span></a>
                    {/if}{/if}</td>

                    <td>
                        {if $item['recordid']==0 || $item['recordid']==99999}
                            <input type="checkbox" name="status[]" data-id="{$item['areaId']}" value="{$item['recordid']}"  {if intval($item['recordid'])==99999} checked="checked" {/if}/>
                        {/if}
                    </td>
                    <td>{$item['notes']}</td>
                    <td style="text-align:right;"> 
                      <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'edit','areaId' =>$item['areaId'],'parentName' =>$shiname));}" title="编辑"><i class="icon-edit"></i>编辑</a>
                      <a href="{php echo createWebUrl('shengshi', array('op' =>'delete','areaId' =>$item['areaId']));}" style="width: 30px" class="btn btn-danger btn-sm" onclick="if(!confirm('确定删除吗,不可恢复')) return false;"  title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                    </td>
                </tr>
                {/loop}
            </tbody>
            </table>
            <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'add','parentId' =>$parentId,'pagelevel' =>3, 'parentName' =>$shiname));}" title="新增"><i class="icon-edit"></i>新增县/区</a>
        </div>
    {else}
        <div class="panel-body table-responsive"> 
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:60px;">序号</th>
                        <th style="width:80px;">全国</th>
                        <th style="width:80px;">省份</th>
                        <th style="width:80px;">市级</th>
                        <th style="width:80px;">县/区</th>
                        <th style="width:80px;">城市级别</th>
                        <th style="width:80px;">加盟状态</th>
                        <th >内定</th>
                        <th >备注</th>
                        <th style=" text-align:right;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $i $item}
                  <tr> 
                    <td>{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td><a href="{php echo createWebUrl('shengshi');}">全国</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' => $item['shengid'],'pagelevel' =>2,'shengname' =>$item['shengname']));}">{$item['shengname']}</a></td>
                    <td><a href="{php echo createWebUrl('shengshi', array('parentId' =>$item['parentId'],'pagelevel' =>3,'shengname' =>$item['shengname'],'shengid' =>$item['shengid'],'shiname' =>$item['shiname']));}">{$item['shiname']}</a></td>
                    <td>{$item['areaName']}</td>
                    <td>{$level[$item['level']]}</td>
                    <td>{if !empty($item['recordid'])}{php echo $item['recordid']==99999?'内定':'已抢定';}{/if}</td>
                    <td>{if !empty($item['recordid'])}
                        {if $item['recordid']==99999}
                            {if $item['recordid']==0 || $item['recordid']==99999}
                                <input type="checkbox" name="status[]" data-id="{$item['areaId']}" value="{$item['recordid']}"  {if intval($item['recordid'])==99999} checked="checked" {/if}/>
                            {/if}
                        {else}
                    <a href="{php echo createWebUrl('record', array('op2' => 'scan','themeid'=>$themeid, 'id' => $item['recordid']));}" title="查看定单" ><span class="label label-success">已抢定{php echo $item['recordid']+10000;}</span></a>
                    {/if}{/if}
                    </td>
                    <td>{$item['notes']}</td>
                    <td style="text-align:right;"> 

                      <a class="btn btn-warning btn-sm" href="{php echo createWebUrl('shengshi', array('op' =>'edit','areaId' =>$item['areaId'],'parentName' =>$shiname));}" title="编辑"><i class="icon-edit"></i>编辑</a>
                    </td>
                </tr>
                {/loop}
            </tbody>
            </table>
        </div>
    {/if}
        {$pager}
    </div>
    </div>

<script type="text/javascript">
    function drop_confirm(msg, url){
        if(confirm(msg)){
            window.location = url;
        }
    }
</script>
<script type="text/javascript">
    $(function(){
        $('.app-preview').click(function(){
            return false;
        });
        require(['underscore', 'bootstrap.switch'], function() {
            $(":checkbox[name='status[]']").bootstrapSwitch();
            $(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
                $this = $(this);
                var id = $(this).data('id');
                var status = this.checked ? 99999 : 0;
                $.post("{php echo createWebUrl($do, array('op' => 'status'));}", {status:status,areaId: id}, function(resp){
                    resp = $.parseJSON(resp);
                    if(resp.message.errno != 0) {
                        layer.msg('操作失败, 请稍后重试');
                    } else {
                        layer.msg('操作成功');
                    }
                });
            });     
            
        });
    });
</script>
